package com.example.cores_middle_activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

public class AlertActivity extends AppCompatActivity implements View.OnClickListener {
    TextView tv_alert;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_alert);

        tv_alert = findViewById(R.id.tv_alert);
        Button btn_alert = findViewById(R.id.btn_alert);
        btn_alert.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Log.d("zhoutao", "onClick: ");
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("主人，主人");
        builder.setMessage("你真的要卸载我妈");
        builder.setPositiveButton("狠心卸载", (dialogInterface, i) -> {
            tv_alert.setText("再见~");
        });

        builder.setNegativeButton("我在想想", (dialogInterface, i) -> tv_alert.setText("还是主人好"));

        AlertDialog dialog = builder.create();
        dialog.show();
    }
}